Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow doctests to span multiple lines with a trailing \ like the REPL already supports #1757

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

glguy
Copy link
Member

@glguy glguy commented Sep 27, 2024

Additionally this allows empty doctest lines to be skipped without error

… already supports

Additionally this allows empty doctest lines to be skipped without error
@glguy glguy marked this pull request as draft September 27, 2024 18:46
@glguy glguy self-assigned this Sep 27, 2024
@glguy glguy marked this pull request as ready for review September 27, 2024 18:50
@glguy glguy added the bug Something not working correctly label Sep 27, 2024
@glguy
Copy link
Member Author

glguy commented Sep 27, 2024

Docstrings were meant to work like the REPL - this was an omission in the initial implementation

where
-- concat that eats leading whitespace between elements
concat' [] = T.empty
concat' (y:ys) = T.concat (y : map (T.dropWhile isSpace) ys)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you have an example like this?

/**
 ** ```repl
 ** :check f 1\
 ** 0
 ** ``` */

Does this get interpreted as :check f 10 or :check f 1 0?

Copy link
Member Author

@glguy glguy Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets interpreted as 10 which is consistent with C (as an example). This will be useful for long literals, too:

x = 0x0123456789abcdef\
      0123456789abcdef\
      0123456789abcdef

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense—thanks for the explanation. It might be worth testing this property in the T02 test case.

@glguy glguy merged commit 8cd51e8 into master Sep 27, 2024
49 checks passed
@glguy glguy deleted the docstring-line-wrap branch September 27, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something not working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants